package com.smarthealthring.mm.presenter;

import android.util.Log;

import com.smarthealthring.mm.api.ApiRequest;
import com.smarthealthring.mm.base.BasePresenter;
import com.smarthealthring.mm.contract.HrDetailContract;
import com.smarthealthring.mm.contract.SleepDetailContract;
import com.smarthealthring.mm.utils.ErrorHanding;
import com.smarthealthring.mm.utils.ToastUtil;

import java.util.Map;

/**
 * Created by bilibili on 2018/5/26.
 */

public class SleepDetailPresenter extends BasePresenter<SleepDetailContract.View> implements SleepDetailContract.Presenter {

    @Override
    public void sleepDetail(Map<String, String> params) {
        addSubscribe(ApiRequest.sleepDetail(params)
                .subscribe(response -> {
                    Log.e("sleepDetail===","success");
                    mView.getSleepDetailSuccess(response);
                }, throwable -> {
                    mView.getSleepDetailFail();
                    Log.e("sleepDetail===",throwable.toString());
                    ToastUtil.shortShow(ErrorHanding.handleError(throwable));
                }));
    }
}
